from datetime import datetime

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, text, DateTime, INTEGER, TIMESTAMP

__all__ = ['Base', 'BaseDbModel']

# 数据库模型基类
Base = declarative_base()


class BaseDbModel(Base):
    __abstract__ = True
    id = Column(INTEGER, primary_key=True, autoincrement=True)
    create_id = Column(INTEGER, server_default=text('0'), comment='创建人')
    create_time = Column(TIMESTAMP, default=datetime.now, comment='创建时间')
    update_id = Column(INTEGER, server_default=text('0'), comment='更新人')
    update_time = Column(TIMESTAMP, default=datetime.now, onupdate=datetime.now, comment='更新时间')
